import { http } from '@/utils/http'

/** 查询参数列表 */
export const listConfig = (params?: object) => {
  return http.request<HttpPaginationResponse<Array<any>>>('get', '/system/config/list', {
    params,
  })
}

/** 查询参数详细 */
export const getConfig = (configId: number) => {
  return http.request<HttpResponse<Object>>('get', '/system/config/' + configId)
}

/** 根据参数键名查询参数值 */
export const getConfigKey = (configKey: string) => {
  return http.request<HttpResponse<Object>>('get', '/system/config/configKey/' + configKey)
}

/** 新增参数配置 */
export const addConfig = (data?: object) => {
  return http.request<HttpResponse<Object>>('post', '/system/config', {
    data,
  })
}

/** 修改参数配置 */
export const updateConfig = (data?: object) => {
  return http.request<HttpResponse<Object>>('put', '/system/config', {
    data,
  })
}

/** 删除参数配置 */
export const delConfig = (configId?: string) => {
  return http.request<HttpResponse<Object>>('delete', '/system/config/' + configId)
}

/** 刷新参数缓存 */
export const refreshCache = () => {
  return http.request<HttpResponse<Object>>('delete', '/system/config/refreshCache')
}
